/***********************************************************
 * Product Name: ExcelQuicker
 * Copyright (c)2005, Eunge
 * Author: Eunge
 * Web Site: www.eudev.net
 * Mail/MSN: eudev.net@yeah.net
 * ********************************************************/
using System;

namespace ExcelQuicker.Framework
{
	/// <summary>
	/// Horizontal and vertical alignment class
	/// </summary>
	/// <remarks>
	/// We can set the alignment of specialize range on excel document
	/// </remarks>
	public class EQAlignment: EQStyleBase
	{
		private Excel.XlHAlign mHorizontalAlign;
		private bool mHFlag;
		private Excel.XlVAlign mVerticalAlign;
		private bool mVFlag;

		/// <summary>
		/// Set/Get horizontal alignment
		/// </summary>
		public Excel.XlHAlign HorizontalAlign
		{
			get
			{
				return this.mHorizontalAlign;
			}
			set
			{
				this.mHorizontalAlign = value;
				this.mHFlag = true;
			}
		}

		/// <summary>
		/// Set/Get vertical alignment
		/// </summary>
		public Excel.XlVAlign VerticalAlign
		{
			get
			{
				return this.mVerticalAlign;
			}
			set
			{
				this.mVerticalAlign = value;
				this.mVFlag = true;
			}
		}

		/// <summary>
		/// Initialize alignment on horizon and vertical
		/// </summary>
		/// <param name="horizontalAlign"></param>
		/// <param name="verticalAlign"></param>
		public EQAlignment(Excel.XlHAlign horizontalAlign, Excel.XlVAlign verticalAlign)
		{
			this.HorizontalAlign = horizontalAlign;
			this.VerticalAlign = verticalAlign;
		}

		/// <summary>
		/// Initialize alignment on horizon
		/// </summary>
		/// <param name="horizontalAlign"></param>
		public EQAlignment(Excel.XlHAlign horizontalAlign)
		{
			this.HorizontalAlign = horizontalAlign;
		}

		/// <summary>
		/// Initialize alignment on vertical
		/// </summary>
		/// <param name="verticalAlign"></param>
		public EQAlignment(Excel.XlVAlign verticalAlign)
		{
			this.VerticalAlign = verticalAlign;
		}

		/// <summary>
		/// Initialize alignment
		/// </summary>
		public EQAlignment()
		{
		}

		/// <summary>
		/// Set alignment of specialized range on excel document
		/// </summary>
		/// <param name="objRange"></param>
		protected internal override void Output(Excel.Range objRange)
		{
			this.DoBeforeOperationEvent(objRange);

			if(this.mHFlag)
				objRange.HorizontalAlignment = this.mHorizontalAlign;

			if(this.mVFlag)
				objRange.VerticalAlignment = this.mVerticalAlign;

			this.DoAfterOperationEvent(objRange);
		}

	}
}
